<template>
  <el-container style="height: 500px; border: 1px solid #eee">
    <el-header class="header1">
      el-submenu 导航条 #el-menu 主要区域容器 # 垂直菜单，可内嵌子菜单。
      通过el-menu-item-group组件可以实现菜单进行分组，分组名可以通过title属性直接设定，也可以通过具名 slot 来设定
    </el-header>
    <el-container>
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds="['1', '3']">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-message"></i>
              导航一
            </template>
            <el-menu-item-group>
              <template slot="title">分组一</template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-menu-item-group>

            <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项4-1</el-menu-item>
                <el-menu-item index="1-4-2">选项4-2</el-menu-item>
                  <el-menu-item index="1-4-3">选项4-3</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>导航二</template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="2-1">选项1</el-menu-item>
          <el-menu-item index="2-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="2-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="2-4">
          <template slot="title">选项4</template>
          <el-menu-item index="2-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title"><i class="el-icon-setting"></i>导航三</template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="3-1">选项1</el-menu-item>
          <el-menu-item index="3-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="3-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="3-4">
          <template slot="title">选项4</template>
          <el-menu-item index="3-4-1">选项4-1</el-menu-item>
        </el-submenu>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container>
        <el-header class="header2" style="text-align: right; font-size: 12px">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>查看</el-dropdown-item>
              <el-dropdown-item>新增</el-dropdown-item>
              <el-dropdown-item>删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>
            el-dropdown 下拉框绑定点击事件
            如果在el-dropdown 里面设置了trigger=”click”属性，即为该控件在点击的时候出现数据。
            如果没有设置该属性，则ElementUI默认为鼠标悬浮事件hover 激活
          </span>
        </el-header>

        <el-main>
          <el-table border :data="tableData">
            <el-table-column prop="date" label="日期" width="140"></el-table-column>
            <el-table-column prop="name" label="姓名" width="120"></el-table-column>
            <el-table-column prop="address" label="地址"></el-table-column>
            <el-table-column fixed="right" width="60" prop="right">
              <template slot-scope="user">
                <el-button
                  @click.native.prevent="deleteRow(user.$index,user.row)"
                  type="text"
                  size="small"
                >移除</el-button>
              </template>
            </el-table-column>
               <el-table-column fixed="right" width="60" prop="right">
              <template >
                <el-button
                  @click.native.prevent="deletedata()"
                  type="text"
                  size="small"
                >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
    </el-container>
  </el-container>
</template>


<script>
export default {
  methods: {
    deleteRow(index, tableData) {
   //  tableData.splice(index, 1);
   this.id=index
     console.log("roe======"+JSON.stringify(tableData))
    },
    deletedata(){
 this.tableData.splice(this.id, 1);
    }
  },
  data() {
    return {
      id:'',
      tableData: [
        {
          date: "2016-05-01",
          name: "基础表格",
          address: "当el-table元素中注入data对象数组后"
        },
        {
          date: "2016",
          name: "prop属性",
          address: "在el-table-column中用prop属性来对应对象中的键名即可填入数据"
        },
        {
          date: "2016-05-04",
          name: "width属性 label属性",
          address: "用label属性来定义表格的列名。可以使用width属性来定义列宽。"
        },
        {
          date: "2016-05-03",
          name: "stripe",
          address:
            "stripe属性可以创建带斑马纹的表格。它接受一个Boolean，默认为false，设置为true即为启用。"
        },
        {
          date: "2016-05-03",
          name: "border",
          address:
            "Table 组件是不具有竖直方向的边框的，如果需要，可以使用border属性，它接受一个Boolean，设置为true即可启用。。"
        }
      ]
    };
    //   const item = {
    //     date: '2016-05-02',
    //     name: '王小虎',
    //     address: '上海市普陀区金沙江路 1518 弄'
    //   };
    //   return {
    //     tableData: Array(10).fill(item)
    //   }
  }
};
</script>


<style>
.header1 {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;

}
.header2 {
  background-color: rgb(231, 26, 26);
  color: #efff7b;
  text-align: center;
}
</style>